﻿using System;
using MultiLanguage.Infrastructure;

namespace MultiLanguage
{
    /// <summary>
    /// An object that can provide calculations
    /// </summary>
    public class TemperatureConverter : ITemperatureConverter
    {
        private const double FahrenheitFactor = 5.0/9.0;
        private const double CelsiusFactor = 9.0/5.0;
        public double ToFahrenheit(double celsius)
        {
            try
            {
                return (CelsiusFactor* celsius) + 32;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return Double.NaN;
        }
        public double ToCelsius(double fahrenheit)
        {
            try
            {
                return FahrenheitFactor*(fahrenheit - 32);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return Double.NaN;
        }
    }
}
